<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>我的审核</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../layui/css/layui.css">
    <script src="../layui/layui.js"></script>
    <style>
        .layui-form-label{
            width: 120px;
            padding: 10px 0;
            text-align: center;
        }
        .layui-form-select .layui-edge{
            right: 50px;
        }
        .layui-form-select .layui-input{
            width: 80%;
        }
        .layui-form-item{
            margin-bottom: 5px;
        }
        .layui-input-date{
            display: block;
            width: 100%;
            padding-left: 10px;
            height: 38px;
            line-height: 38px\9;
            border-width: 1px;
            border-style: solid;
            background-color: #fff;
            color: rgba(0,0,0,.85);
            border-radius: 2px;
            border-color: #eee;
            outline: 0;
            -webkit-appearance: none;
            transition: all .3s;
            -webkit-transition: all .3s;
            box-sizing: border-box;
        }
    </style>
</head>
<body>
<div class="layui-tab layui-tab-card">
    <ul class="layui-tab-title">
        <li class="layui-this bigfont" style="color:#1e1e93 ;font-size: 17px;font-weight: 1000;">未完成审核
            <div id="unFinished" style="position: absolute;color: white;font-size: 10px;background-color:red;min-height: 10px;min-width: 10px;line-height: 10px;right: -7%;top:1px;right:3px;text-align: center;-webkit-border-radius: 24px;border-radius: 24px;padding: 2px">
                <p id="unfinishedprocessauditingNum"></p>
            </div>
        </li>
        <li class="bigfont" style="color:#3ea53e;font-size: 17px;font-weight: 1000;">已完成审核
            <div id="finished" style="position: absolute;color: white;font-size: 10px;background-color:red;min-height: 10px;min-width: 10px;line-height: 10px;right: -7%;top:1px;right:3px;text-align: center;-webkit-border-radius: 24px;border-radius: 24px;padding: 2px">
                <p id="finishedprocessauditingNum"></p>
            </div>
        </li>
        <li class="bigfont" style="color:#3ea53e;font-size: 17px;font-weight: 1000;">抄送给我
            <div id="copy" style="position: absolute;color: white;font-size: 10px;background-color:red;min-height: 10px;min-width: 10px;line-height: 10px;right: -7%;top:1px;right:3px;text-align: center;-webkit-border-radius: 24px;border-radius: 24px;padding: 2px">
                <p id="copyprocessNum"></p>
            </div>
        </li>
    </ul>
    <!--表格-->
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <table class="layui-hide" id="unfinishedprocessauditing" lay-filter="processauditing"></table>
        </div>
        <div class="layui-tab-item">
            <table class="layui-hide" id="finishedprocessauditing" lay-filter="processauditing"></table>
        </div>
        <div class="layui-tab-item">
            <table class="layui-hide" id="copyprocess" lay-filter="processauditing"></table>
        </div>
    </div>
</div>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="detail" >查看详情
        {{#  if(d.isRead == 0){ }}
        <div id="isRead" style="width: 9px;height: 9px;border-radius: 50%;background-color: red;display: inline-block;position: absolute;margin-top: 0px;"></div>
        {{#  } }}
    </a>
    {{# if(d.positionId === 32 && d.processType === 3 ){ }}
    <a class="layui-btn layui-btn-xs" lay-event="contract">一键签署</a>
    {{# } }}

</script>
<!--<script type="text/html" id="barDemo1">-->
<!--    <a class="layui-btn layui-btn-xs" lay-event="detail1">查看详情-->
<!--        {{#  if(d.isRead == 0){ }}-->
<!--        <div id="isRead1" style="width: 9px;height: 9px;border-radius: 50%;background-color: red;display: inline-block;position: absolute;margin-top: 0px;"></div>-->
<!--        {{#  } }}-->
<!--    </a>-->
<!--</script>-->

<!--未完成审核-->
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container" style="display: inline-block">
        <button class="layui-btn layui-btn-sm" lay-event="flush">刷新</button>
    </div>
    <!--搜索框-->
    <div style="display: inline-block" class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">申请人:</label>
            <div class="layui-input-inline">
                <input type="text" name="applyRealName" id="applyRealName" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">(成交单)用户姓名:</label>
            <div class="layui-input-inline">
                <input type="text" name="name" id="name" autocomplete="off" class="layui-input" >
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">(成交单)电话:</label>
            <div class="layui-input-inline">
                <input type="text" name="telephone" id="telephone" autocomplete="off" class="layui-input" >
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">(成交单)收款方式:</label>
            <div class="layui-input-inline">
                <input type="text" name="paymentMethod" id="paymentMethod" autocomplete="off" class="layui-input" >
            </div>
        </div>
        <div class="layui-inline" style="display: inline-block">
            <label class="layui-form-label" style="display: inline-block">(成交单)转账日期:</label>
            <div class="layui-input-inline" style="display: inline-block">
                <input type="text" name="transferDateStart" id="transferDateStart" autocomplete="off" placeholder="yyyy-MM-dd" class="layui-input-date">
            </div>
            <label class="layui-form-label" style="display: inline-block;width: 40px;text-align: center;padding-left: 0px">——</label>
            <div class="layui-input-inline" style="display: inline-block">
                <input type="text" name="transferDateEnd" id="transferDateEnd" autocomplete="off" placeholder="yyyy-MM-dd"  class="layui-input-date">
            </div>
        </div>
        <div class="layui-inline" style="display: inline-block">
            <label class="layui-form-label" style="display: inline-block">申请时间:</label>
            <div class="layui-input-inline" style="display: inline-block">
                <input type="text" name="applyTimeStart" id="applyTimeStart" autocomplete="off" placeholder="yyyy-MM-dd"  class="layui-input-date">
            </div>
            <label class="layui-form-label" style="display: inline-block;width: 40px;text-align: center;padding-left: 0px">——</label>
            <div class="layui-input-inline" style="display: inline-block">
                <input type="text" name="applyTimeEnd" id="applyTimeEnd" autocomplete="off" placeholder="yyyy-MM-dd"  class="layui-input-date">
            </div>
        </div>
        <div class="layui-form-item"style="display: inline-block">
            <label class="layui-form-label">流程类型:</label>
            <div class="layui-input-block">
                <select id="processType" name="processType" >
                    <option selected></option>
                    <option value="0">请假单</option>
                    <option value="1">异常考勤</option>
                    <option value="2">入职单</option>
                    <option value="3">成交单(全款)</option>
                    <option value="4">采购单</option>
                    <option value="5">离职单</option>
                    <option value="6">转正单</option>
                    <option value="7">合规单</option>
                    <option value="8">成交单(非全款)</option>
                    <option value="9">退款单(365)</option>
                    <option value="10">退款单(大额)</option>
                    <option value="11">报销单</option>
                    <option value="14">投诉单</option>
                    <option value="15">借款单</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-btn-container" style="display: inline-block">
        <button class="layui-btn layui-btn-sm" lay-event="select" id="select">查询</button>
    </div>
    <div class="layui-btn-container" style="display: inline-block">
        <button class="layui-btn layui-btn-sm" lay-event="clear" >清除</button>
    </div>
</script>
<!--已完成审核-->
<script type="text/html" id="toolbarDemo1">
    <div class="layui-btn-container" style="display: inline-block">
        <button class="layui-btn layui-btn-sm" lay-event="flush1">刷新</button>
    </div>
    <!--搜索框-->
    <div style="" class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">申请人:</label>
            <div class="layui-input-inline">
                <input type="text" name="applyRealName1" id="applyRealName1" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">(成交单)用户姓名:</label>
            <div class="layui-input-inline">
                <input type="text" name="name1" id="name1" autocomplete="off" class="layui-input" >
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">(成交单)电话:</label>
            <div class="layui-input-inline">
                <input type="text" name="telephone1" id="telephone1" autocomplete="off" class="layui-input" >
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">(成交单)收款方式:</label>
            <div class="layui-input-inline">
                <input type="text" name="paymentMethod1" id="paymentMethod1" autocomplete="off" class="layui-input" >
            </div>
        </div>
        <div class="layui-inline" style="display: inline-block">
            <label class="layui-form-label" style="display: inline-block">(成交单)转账日期:</label>
            <div class="layui-input-inline" style="display: inline-block">
                <input type="text" name="transferDateStart1" id="transferDateStart1" autocomplete="off" placeholder="yyyy-MM-dd"  class="layui-input-date">
            </div>
            <label class="layui-form-label" style="display: inline-block;width: 40px;text-align: center;padding-left: 0px">——</label>
            <div class="layui-input-inline" style="display: inline-block">
                <input type="text" name="transferDateEnd1" id="transferDateEnd1" autocomplete="off" placeholder="yyyy-MM-dd"  class="layui-input-date">
            </div>
        </div>
        <div class="layui-inline" style="display: inline-block">
            <label class="layui-form-label" style="display: inline-block">申请时间:</label>
            <div class="layui-input-inline" style="display: inline-block">
                <input type="text" name="applyTimeStart1" id="applyTimeStart1" autocomplete="off" placeholder="yyyy-MM-dd"  class="layui-input-date">
            </div>
            <label class="layui-form-label" style="display: inline-block;width: 40px;text-align: center;padding-left: 0px">——</label>
            <div class="layui-input-inline" style="display: inline-block">
                <input type="text" name="applyTimeEnd1" id="applyTimeEnd1" autocomplete="off"  placeholder="yyyy-MM-dd" class="layui-input-date">
            </div>
        </div>
        <div class="layui-form-item"style="display: inline-block">
            <label class="layui-form-label">流程类型:</label>
            <div class="layui-input-block">
                <select id="processType1" name="processType1" >
                    <option selected></option>
                    <option value="0">请假单</option>
                    <option value="1">异常考勤</option>
                    <option value="2">入职单</option>
                    <option value="3">成交单(全款)</option>
                    <option value="4">采购单</option>
                    <option value="5">离职单</option>
                    <option value="6">转正单</option>
                    <option value="7">合规单</option>
                    <option value="8">成交单(非全款)</option>
                    <option value="9">退款单(365)</option>
                    <option value="10">退款单(大额)</option>
                    <option value="11">报销单</option>
                    <option value="14">投诉单</option>
                    <option value="15">借款单</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-btn-container" style="display: inline-block">
        <button class="layui-btn layui-btn-sm" lay-event="select1" id="select1">查询</button>
    </div>
    <div class="layui-btn-container" style="display: inline-block">
        <button class="layui-btn layui-btn-sm" lay-event="clear1" >清除</button>
    </div>
</script>
<!--抄送给我-->
<script type="text/html" id="toolbarDemo2">
    <div class="layui-btn-container" style="display: inline-block">
        <button class="layui-btn layui-btn-sm" lay-event="flush2">刷新</button>
    </div>
    <!--搜索框-->
    <div style="" class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">申请人:</label>
            <div class="layui-input-inline">
                <input type="text" name="applyRealName2" id="applyRealName2" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">(成交单)用户姓名:</label>
            <div class="layui-input-inline">
                <input type="text" name="name2" id="name2" autocomplete="off" class="layui-input" >
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">(成交单)电话:</label>
            <div class="layui-input-inline">
                <input type="text" name="telephone2" id="telephone2" autocomplete="off" class="layui-input" >
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">(成交单)收款方式:</label>
            <div class="layui-input-inline">
                <input type="text" name="paymentMethod2" id="paymentMethod2" autocomplete="off" class="layui-input" >
            </div>
        </div>
        <div class="layui-inline" style="display: inline-block">
            <label class="layui-form-label" style="display: inline-block">(成交单)转账日期:</label>
            <div class="layui-input-inline" style="display: inline-block">
                <input type="text" name="transferDateStart2" id="transferDateStart2" autocomplete="off" placeholder="yyyy-MM-dd"  class="layui-input-date">
            </div>
            <label class="layui-form-label" style="display: inline-block;width: 40px;text-align: center;padding-left: 0px">——</label>
            <div class="layui-input-inline" style="display: inline-block">
                <input type="text" name="transferDateEnd2" id="transferDateEnd2" autocomplete="off" placeholder="yyyy-MM-dd"  class="layui-input-date">
            </div>
        </div>
        <div class="layui-inline" style="display: inline-block">
            <label class="layui-form-label" style="display: inline-block">申请时间:</label>
            <div class="layui-input-inline" style="display: inline-block">
                <input type="text" name="applyTimeStart2" id="applyTimeStart2" autocomplete="off"  placeholder="yyyy-MM-dd" class="layui-input-date"  >
            </div>
            <label class="layui-form-label" style="display: inline-block;width: 40px;text-align: center;padding-left: 0px">——</label>
            <div class="layui-input-inline" style="display: inline-block">
                <input type="text" name="applyTimeEnd2" id="applyTimeEnd2" autocomplete="off" placeholder="yyyy-MM-dd" class="layui-input-date">
            </div>
        </div>
        <div class="layui-form-item"style="display: inline-block">
            <label class="layui-form-label">流程类型:</label>
            <div class="layui-input-block">
                <select id="processType2" name="processType2" >
                    <option selected></option>
                    <option value="0">请假单</option>
                    <option value="1">异常考勤</option>
                    <option value="2">入职单</option>
                    <option value="3">成交单(全款)</option>
                    <option value="4">采购单</option>
                    <option value="5">离职单</option>
                    <option value="6">转正单</option>
                    <option value="7">合规单</option>
                    <option value="8">成交单(非全款)</option>
                    <option value="9">退款单(365)</option>
                    <option value="10">退款单(大额)</option>
                    <option value="11">报销单</option>
                    <option value="14">投诉单</option>
                    <option value="15">借款单</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-btn-container" style="display: inline-block">
        <button class="layui-btn layui-btn-sm" lay-event="select2" id="select2">查询</button>
    </div>
    <div class="layui-btn-container" style="display: inline-block">
        <button class="layui-btn layui-btn-sm" lay-event="clear2" >清除</button>
    </div>
</script>


<script th:inline=none>
    layui.use(['table', 'dropdown'], function(){
        var table = layui.table;
        var dropdown = layui.dropdown;
        var unfinishedprocessauditingNum = -1;//统计未完成审核的未读消息数量
        var finishedprocessauditingNum = -1;//统计已完成审核的未读消息的数量
        var copyprocessNum = -1;//统计抄送给我的未读消息的数量
        hideTheRedDotsForFirst();//第一次加载的时候隐藏未读消息的红点

        // 创建渲染实例
        table.render({
            elem: '#unfinishedprocessauditing',
            id:'unfinishedprocessauditing'
            ,url:'/process/myunfinishedprocessauditing'
            ,toolbar: '#toolbarDemo',
            response: {
                statusCode: 10000 //规定成功的状态码，默认：0
            },
            height: 'full-0'
            , limit:20,
            limits:[20]
            ,cellMinWidth: 80
            ,page: true,
            done: function() {

            },cols: [[{field:'processType',  title: '流程类型',templet: function(d) {
                    if (d.processType == 0||d.processType == 12||d.processType == 13) {
                        return '<span>请假单</span>';
                    }
                    if (d.processType == 1) {
                        return '<span>异常考勤</span>';
                    }
                    if (d.processType == 2) {
                        return '<span>入职单</span>';
                    }
                    //成交单3 直接完成 全款
                    if (d.processType == 3) {
                        return '<span>成交单</span>';
                    }
                    if (d.processType == 4) {
                        return '<span>采购单</span>';
                    }
                    if (d.processType == 5||d.processType == 16||d.processType == 17) {
                        return '<span>离职单</span>';
                    }
                    if (d.processType ==6) {
                        return '<span>转正单</span>';
                    }
                    if (d.processType ==7) {
                        return '<span>合规单</span>';
                    }
                    //成交单8 非全款 待补款的
                    if (d.processType ==8) {
                        return '<span>成交单</span>';
                    }
                    if (d.processType == 9) {
                        return '<span>退款单</span>';
                    }
                    if (d.processType == 10) {
                        return '<span>退款单</span>';
                    }
                    if (d.processType ==11) {
                        return '<span>报销单</span>';
                    }
                    if (d.processType ==14) {
                        return '<span>投诉单</span>';
                    }
                    if (d.processType ==15) {
                        return '<span>借款单</span>';
                    }
                }},
                {field:'paymentWay',  title: '单据类型',templet: function(d) {

                        if (d.paymentWay == 2 || d.paymentWay == 3) {
                            return '<span>定金成交单</span>';
                        }
                        if (d.paymentWay == 1) {
                            return '<span>全款成交单</span>';
                        }
                        if (d.paymentWay == 4) {
                            return '<span>365退款单</span>';
                        }
                        if (d.paymentWay == 5) {
                            return '<span>大额退款单</span>';
                        }
                        if (d.paymentWay == 0 || d.paymentWay == null) {
                            return '<span>&nbsp;</span>';
                        }
                    }},
                {field:'applyRealName',  title: '申请人'},
                {field:'auditerStatus',  title:'流程审核状态',templet: function(d) {

                        if (d.auditerStatus === 200) {
                            return '<span style="color: red;">审核驳回</span>';
                        }if(d.auditerStatus == 100){
                            return '<b style="color:green">审核通过</b>';
                        }if(d.auditerStatus == 0){
                            return '<b >未审核</b>';
                        }else {
                            return '<b style="color:#806a00">审核中</b>';
                        }
                    }},
                {field:'auditingPersonRealName',  title:'当前审核人'},
                {field:'departmentName',  title: '所属部门'
                },
                {field:'applyTime',  title: '流程申请时间',templet: function(d){ if(d.applyTime==null){
                        return '暂无'} else  return todatestr(d.applyTime)}
                }
                // ,{field:'endTime',  title: '流程结束时间',templet: function(d){ if(d.endTime==null){
                //         return '暂无'} else  return todatestr(d.endTime)}
                // }
                // ,{field:'duration',  title: '流程总天数'}
                ,{title:'操作',  toolbar: '#barDemo'}
            ]],
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.list //解析数据列表
                };
            },
            error: function(res, msg){
                console.log(res, msg)
            }
        });
        table.render({
            elem: '#finishedprocessauditing'
            ,url:'/process/myfinishedprocessauditing'
            ,id:'finishedprocessauditing'
            ,toolbar: '#toolbarDemo1',
            response: {
                statusCode: 10000 //规定成功的状态码，默认：0
            },
            height: 'full-0'
            , limit:20,
            limits:[20]
            ,cellMinWidth: 80
            ,page: true,
            done: function() {

            }
            ,cols: [[{field:'processType',  title: '流程类型',templet: function(d) {
                    if (d.processType == 0||d.processType == 12||d.processType == 13) {
                        return '<span>请假单</span>';
                    }
                    if (d.processType == 1) {
                        return '<span>异常考勤</span>';
                    }
                    if (d.processType == 2) {
                        return '<span>入职单</span>';
                    }
                    if (d.processType == 3 || d.processType == 8) {
                        return '<span>成交单</span>';
                    }
                    if (d.processType == 4) {
                        return '<span>采购单</span>';
                    }
                    if (d.processType == 5||d.processType == 16||d.processType == 17) {
                        return '<span>离职单</span>';
                    }
                    if (d.processType == 6) {
                        return '<span>转正单</span>';
                    }
                    if (d.processType == 7) {
                        return '<span>合规单</span>';
                    }
                    if (d.processType == 9) {
                        return '<span>退款单</span>';
                    }
                    if (d.processType == 10) {
                        return '<span>退款单</span>';
                    }
                    if (d.processType == 11) {
                        return '<span>报销单</span>';
                    }
                    if (d.processType == 14) {
                        return '<span>投诉单</span>';
                    }
                    if (d.processType ==15) {
                        return '<span>借款单</span>';
                    }
                }},
                {field:'paymentWay',  title: '单据类型',templet: function(d) {
                        if (d.paymentWay == 2 || d.paymentWay == 3) {
                            return '<span>定金成交单</span>';
                        }
                        if (d.paymentWay == 1) {
                            return '<span>全款成交单</span>';
                        }
                        if (d.paymentWay == 4) {
                            return '<span>365退款单</span>';
                        }
                        if (d.paymentWay == 5) {
                            return '<span>大额退款单</span>';
                        }
                        if (d.paymentWay == 0 || d.paymentWay == null) {
                            return '<span>&nbsp; </span>';
                        }
                    }},
                {field:'applyRealName',  title: '申请人'},
                {field:'auditerStatus',  title:'流程审核状态',templet: function(d) {
                        if (d.auditerStatus === 200) {
                            return '<span style="color: red;">审核驳回</span>';
                        }if(d.auditerStatus == 100){
                            return '<b style="color:green">审核通过</b>';
                        }if(d.auditerStatus == 0){
                            return '<b >未审核</b>';
                        }else {
                            return '<b style="color:#806a00">审核中</b>';
                        }
                    }},
                {field:'auditingPersonRealName',  title:'当前审核人'},
                {field:'applyTime',  title: '流程申请时间',templet: function(d){ if(d.applyTime==null){
                        return '暂无'} else  return todatestr(d.applyTime)}
                },
                {field:'departmentName',  title: '所属部门'
                }
                // ,{field:'endTime',  title: '流程结束时间',templet: function(d){ if(d.endTime==null){
                //         return '暂无'} else  return todatestr(d.endTime)}
                // }
                // ,{field:'duration',  title: '流程总天数'}
                ,{title:'操作',  toolbar: '#barDemo'}
            ]],
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.list //解析数据列表
                };
            }
            ,error: function(res, msg){
                console.log(res, msg)
            }
        });
        table.render({
            elem: '#copyprocess'
            ,url:'/process/copyforme'
            ,id:'copyprocess'
            ,toolbar: '#toolbarDemo2',
            response: {
                statusCode: 10000 //规定成功的状态码，默认：0
            },
            height: 'full-0'
            , limit:20,
            limits:[20]
            ,cellMinWidth: 80
            ,page: true,
            done: function() {

            }
            ,cols: [[{field:'processType',  title: '流程类型',templet: function(d) {
                    if (d.processType == 0||d.processType == 12||d.processType == 13) {
                        return '<span>请假单</span>';
                    }
                    if (d.processType == 1) {
                        return '<span>异常考勤</span>';
                    }
                    if (d.processType == 2) {
                        return '<span>入职单</span>';
                    }
                    if (d.processType == 3 || d.processType == 8) {
                        return '<span>成交单</span>';
                    }
                    if (d.processType == 4) {
                        return '<span>采购单</span>';
                    }
                    if (d.processType == 5||d.processType == 16||d.processType == 17) {
                        return '<span>离职单</span>';
                    }
                    if (d.processType == 6) {
                        return '<span>转正单</span>';
                    }
                    if (d.processType == 7) {
                        return '<span>合规单</span>';
                    }
                    if (d.processType == 9) {
                        return '<span>退款单</span>';
                    }
                    if (d.processType == 10) {
                        return '<span>退款单</span>';
                    }
                    if (d.processType == 11) {
                        return '<span>报销单</span>';
                    }
                    if (d.processType == 14) {
                        return '<span>投诉单</span>';
                    }
                    if (d.processType ==15) {
                        return '<span>借款单</span>';
                    }
                }},
                {field:'paymentWay',  title: '单据类型',templet: function(d) {

                        if (d.paymentWay == 2 || d.paymentWay == 3) {
                            return '<span>定金成交单</span>';
                        }
                        if (d.paymentWay == 1) {
                            return '<span>全款成交单</span>';
                        }
                        if (d.paymentWay == 4) {
                            return '<span>365退款单</span>';
                        }
                        if (d.paymentWay == 5) {
                            return '<span>大额退款单</span>';
                        }
                        if (d.paymentWay == 0 || d.paymentWay == null) {
                            return '<span>&nbsp; </span>';
                        }
                    }},
                {field:'applyRealName',  title: '申请人'},
                {field:'auditerStatus',  title:'流程审核状态',templet: function(d) {
                        if (d.auditerStatus === 200) {
                            return '<span style="color: red;">审核驳回</span>';
                        }if(d.auditerStatus == 100){
                            return '<b style="color:green">审核通过</b>';
                        }if(d.auditerStatus == 0){
                            return '<b >未审核</b>';
                        }else {
                            return '<b style="color:#806a00">审核中</b>';
                        }
                    }},
                {field:'auditingPersonRealName',  title:'当前审核人'},
                {field:'applyTime',  title: '流程申请时间',templet: function(d){ if(d.applyTime==null){
                        return '暂无'} else  return todatestr(d.applyTime)}
                },
                {field:'departmentName',  title: '所属部门'
                }
                ,{title:'操作',  toolbar: '#barDemo'}
            ]],
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.list //解析数据列表
                };
            }
            ,error: function(res, msg){
                console.log(res, msg)
            }
        });
        var $=layui.$
        $(".layui-tab-title li:nth-child(1)").click(function() {

            console.log("dssaddsa1")
            table.reload('unfinishedprocessauditing',{page: {curr: 1},where:{}});
            layui.use(function() {
                var laydate = layui.laydate;
                // 自定义格式
                //实现时间输入框全框触发
                layui.use(function() {
                    var laydate = layui.laydate;
                    // 自定义格式
                    laydate.render({
                        elem: '.layui-input-date',
                        trigger:'click'
                    });
                });
            });
        });
        $(".layui-tab-title li:nth-child(2)").click(function() {
            console.log("dssaddsa2")
            table.reload('finishedprocessauditing',{page: {curr: 1},where:{}});
            //实现时间输入框全框触发
            layui.use(function() {
                var laydate = layui.laydate;
                // 自定义格式
                laydate.render({
                    elem: '.layui-input-date',
                    trigger:'click'
                });
            });
        });
        $(".layui-tab-title li:nth-child(3)").click(function() {
            console.log("dssaddsa3")
            table.reload('copyprocess',{page: {curr: 1},where:{}});
            //实现时间输入框全框触发
            layui.use(function() {
                var laydate = layui.laydate;
                // 自定义格式
                laydate.render({
                    elem: '.layui-input-date',
                    trigger:'click'
                });
            });
        });


            // 封装获取合同信息并更新下拉框的函数
            function loadAndFillContracts() {
                $.ajax({
                    type: "GET",
                    url: "/process/contracts",
                    success: function(response) {
                        console.log("合同", response);
                        var contracts = JSON.parse(response); // 将返回的 JSON 字符串解析为 JavaScript 对象数组
                        var selectOptions = contracts.map(function(item) {
                            return '<option value="' + item.contractName + ',' + item.templateId + ',' + item.contractId + '">' + item.contractName + '</option>';
                        });

                        $('#templateSelector').html(selectOptions.join('')); // 确保将数组转换为字符串
                    },
                    error: function() {
                        console.log("请求失败");
                    }
                });
            }

        table.on('tool(processauditing)', function(obj){
            var data = obj.data;

            if(obj.event === 'detail'){
                        updateIsRead(data.id);//查看详情的时候消除小红点
                        layer.open({
                            type: 2,
                            title: '单据展示',
                            shadeClose: true,
                            shade: 0.8,
                            area: ['1200px', '800px'],
                            content: '/process/processdetailpage?id='+data.id+'&processType='+data.processType+'&isauditing=1'
                });
                window.addEventListener('message', function(event) {
                    if(event.data===obj.data.id){
                        var formdata=table.getData("myprocess")
                        if(formdata.length===1){
                            table.reload("myprocess", {
                                page: {curr: obj.prev} // 重新加载上一页的数据
                            });
                        }else {
                            obj.del()
                        }
                    }
                });
            } else if (obj.event === 'contract') {
                // 调用函数，获取合同信息并填充下拉框
                loadAndFillContracts();
                // 弹出下拉框
                layer.open({
                    title: '请按需选择合同',
                    content: '<input type="text" id="oldAgreementNumber" placeholder="请输入旧合同编号"><br><br><select id="templateSelector"></select><br>',
                    area: ['auto', 'auto'],
                    btn: ['确定', '取消'],
                    end: function() {
                        // 调用函数，获取合同信息并填充下拉框
                        loadAndFillContracts();
                    },
                    yes: function(index, layero){
                        var oldAgreementNumber = $('#oldAgreementNumber').val();
                        var templateSelector = $('#templateSelector').val();

                        var values = templateSelector.split(',');
                        var contractName = values[0];
                        var templateId = values[1];
                        var contractId = values[2];

                        // 当contractId为4时，检查oldAgreementNumber是否为空
                        if(contractId === '4' && !oldAgreementNumber) {
                            // 使用layer.msg显示提示信息
                            layer.msg('补款,升级,续费，旧合同编号不能为空！');
                            return; // 阻止代码继续执行
                        }

                        var requestData = {
                            id: data.id,
                            oldAgreementNumber: oldAgreementNumber,
                            contractName: contractName,
                            templateId: templateId,
                            contractId: contractId
                        };
                        // console.log("requestData: ",requestData)

                        $.ajax({
                            type: "POST",
                            url: "/process/postContract",
                            contentType: "application/json",
                            dataType: 'json',
                            data: JSON.stringify(requestData),
                            success: function(response) {
                                console.log(response)
                                console.log(response.code)
                                if(response.code == 0) {
                                    parent.layer.msg('成功发起合同签署');
                                    location.reload();
                                } else {
                                    // console.log("返回的数据不符合预期", response);
                                    parent.layer.msg('操作未成功，'+response.message+',请稍后再试或联系管理员。',{time: 5000});
                                }
                            },
                            error: function(jqXHR, textStatus, errorThrown) {
                                console.log("请求失败", textStatus, errorThrown);
                                // 尝试从响应体中获取错误信息
                                var errorMsg = '请求失败，请仔细核对用户信息是否正确或联系管理员。';
                                if(jqXHR.responseJSON && jqXHR.responseJSON.message) {
                                    errorMsg += ' 错误详情: ' + jqXHR.responseJSON.message;
                                } else if(errorThrown) {
                                    errorMsg += ' 错误详情: ' + errorThrown;
                                }
                                parent.layer.msg(errorMsg, {time: 5000}); // 这里设置消息显示5秒
                            }
                        });

                        layer.close(index);
                    },
                    btn2: function(index, layero){
                        layer.close(index);
                        // location.reload();
                    }
                });
            }
            layui.use(function() {
                var laydate = layui.laydate;
                // 自定义格式
                laydate.render({
                    elem: '.layui-input-date',
                    trigger:'click'
                });
            });
        });

        table.on('toolbar(processauditing)', function(obj){
            switch(obj.event){
                //刷新用
                case 'flush':
                    table.reload('unfinishedprocessauditing',{page: {curr: 1},where:{}});
                    break;
                case 'flush1':
                    table.reload('finishedprocessauditing',{page: {curr: 1},where:{}});
                    break;
                case 'flush2':
                    table.reload('copyprocess',{page: {curr: 1},where:{}});
                    break;
                //根据条件查找用
                case 'select':
                    var selectData = getInputs(0);
                    table.reloadData('unfinishedprocessauditing',{page: {curr: 1},where:{applyRealName:selectData.applyRealName,name:selectData.name,
                            telephone:selectData.telephone,paymentMethod:selectData.paymentMethod,
                            transferDateStart:selectData.transferDateStart,transferDateEnd:selectData.transferDateEnd,
                            applyTimeStart:selectData.applyTimeStart,applyTimeEnd:selectData.applyTimeEnd,
                            processType:selectData.processType}})
                    //留存数据
                    $('input[name="applyRealName"]').val(selectData.applyRealName);
                    $('input[name="name"]').val(selectData.name);
                    $('input[name="telephone"]').val(selectData.telephone);
                    $('input[name="paymentMethod"]').val(selectData.paymentMethod);
                    $('input[name="transferDateStart"]').val(selectData.transferDateStart);
                    $('input[name="transferDateEnd"]').val(selectData.transferDateEnd);
                    $('input[name="applyTimeStart"]').val(selectData.applyTimeStart);
                    $('input[name="applyTimeEnd"]').val(selectData.applyTimeEnd);
                    $('select[name="processType"]').val(selectData.processType);
                    break;
                case 'select1':
                    var selectData = getInputs(1);
                    table.reloadData('finishedprocessauditing',{page: {curr: 1},where:{applyRealName:selectData.applyRealName,name:selectData.name,
                            telephone:selectData.telephone,paymentMethod:selectData.paymentMethod,
                            transferDateStart:selectData.transferDateStart,transferDateEnd:selectData.transferDateEnd,
                            applyTimeStart:selectData.applyTimeStart,applyTimeEnd:selectData.applyTimeEnd,processType:selectData.processType}})
                    //留存数据
                    $('input[name="applyRealName1"]').val(selectData.applyRealName);
                    $('input[name="name1"]').val(selectData.name);
                    $('input[name="telephone1"]').val(selectData.telephone);
                    $('input[name="paymentMethod1"]').val(selectData.paymentMethod);
                    $('input[name="transferDateStart1"]').val(selectData.transferDateStart);
                    $('input[name="transferDateEnd1"]').val(selectData.transferDateEnd);
                    $('input[name="applyTimeStart1"]').val(selectData.applyTimeStart);
                    $('input[name="applyTimeEnd1"]').val(selectData.applyTimeEnd);
                    $('select[name="processType1"]').val(selectData.processType);
                    break;
                case 'select2':
                    var selectData = getInputs(2);
                    table.reloadData('copyprocess',{page: {curr: 1},where:{applyRealName:selectData.applyRealName,name:selectData.name,
                            telephone:selectData.telephone,paymentMethod:selectData.paymentMethod,
                            transferDateStart:selectData.transferDateStart,transferDateEnd:selectData.transferDateEnd,
                            applyTimeStart:selectData.applyTimeStart,applyTimeEnd:selectData.applyTimeEnd,processType:selectData.processType}})
                    //留存数据
                    $('input[name="applyRealName2"]').val(selectData.applyRealName);
                    $('input[name="name2"]').val(selectData.name);
                    $('input[name="telephone2"]').val(selectData.telephone);
                    $('input[name="paymentMethod2"]').val(selectData.paymentMethod);
                    $('input[name="transferDateStart2"]').val(selectData.transferDateStart);
                    $('input[name="transferDateEnd2"]').val(selectData.transferDateEnd);
                    $('input[name="applyTimeStart2"]').val(selectData.applyTimeStart);
                    $('input[name="applyTimeEnd2"]').val(selectData.applyTimeEnd);
                    $('select[name="processType2"]').val(selectData.processType);
                    break;
                case 'clear' :
                    clearInput(0);
                    break;
                case 'clear1' :
                    clearInput(1);
                    break;
                case 'clear2' :
                    clearInput(2);
                    break;

            };
            //实现时间输入框全框触发
            layui.use(function() {
                var laydate = layui.laydate;
                // 自定义格式
                laydate.render({
                    elem: '.layui-input-date',
                    trigger:'click'
                });
            });
        });
        function  todatestr(s){
            var timestamp = new Date(s);
            let y = timestamp.getFullYear()
            let m = timestamp.getMonth() + 1
            m = m < 10 ? ('0' + m) : m
            let d = timestamp.getDate()
            d = d < 10 ? ('0' + d) : d
            let h =timestamp.getHours()
            h = h < 10 ? ('0' + h) : h
            let M =timestamp.getMinutes()
            M = M < 10 ? ('0' + M) : M
            let S =timestamp.getSeconds()
            S= S< 10 ? ('0' + S) :S
            let dateTime= y + '-' + m + '-' + d+ '  ' + h+':'+ M+':'+S
            return  dateTime;
        };
        //获取每个输入框的值赋值给selectData对象
        function getInputs(selectNum){
            var selectData = new Object();
            // if (!/^1[3456789]\d{9}$/.test(document.getElementsByTagName('input')[2].value)){
            //     alert("请输入正确的电话号");
            //     return "电话号码不规范"
            // }
            if (selectNum == 0){
                selectData.applyRealName = $('#applyRealName').val();
                selectData.name = $('#name').val();
                selectData.telephone = $('#telephone').val();
                selectData.paymentMethod = $('#paymentMethod').val();
                selectData.transferDateStart = $('#transferDateStart').val();
                selectData.transferDateEnd = $('#transferDateEnd').val();
                selectData.applyTimeStart = $('#applyTimeStart').val();
                selectData.applyTimeEnd = $('#applyTimeEnd').val();
                selectData.processType = document.getElementById("processType").value;
            }else if(selectNum == 1){
                selectData.applyRealName = $('#applyRealName1').val();
                selectData.name = $('#name1').val();
                selectData.telephone = $('#telephone1').val();
                selectData.paymentMethod = $('#paymentMethod1').val();
                selectData.transferDateStart = $('#transferDateStart1').val();
                selectData.transferDateEnd = $('#transferDateEnd1').val();
                selectData.applyTimeStart = $('#applyTimeStart1').val();
                selectData.applyTimeEnd = $('#applyTimeEnd1').val();
                selectData.processType = document.getElementById("processType1").value;
            }else if (selectNum == 2){
                selectData.applyRealName = $('#applyRealName2').val();
                selectData.name = $('#name2').val();
                selectData.telephone = $('#telephone2').val();
                selectData.paymentMethod = $('#paymentMethod2').val();
                selectData.transferDateStart = $('#transferDateStart2').val();
                selectData.transferDateEnd = $('#transferDateEnd2').val();
                selectData.applyTimeStart = $('#applyTimeStart2').val();
                selectData.applyTimeEnd = $('#applyTimeEnd2').val();
                selectData.processType = document.getElementById("processType2").value;
            }
            return selectData;
        };
        //解决input为date时value获取不到值的问题
        $(".layui-input-date").change(function(){
            $("#layui-input-date").attr("value",$(this).val()); //赋值
        });
        //实现点击后红点消失
        window.updateIsRead = function (id){
            $.ajax({
                url:"/HasBeenRead/deleteHasBeenRead",
                data:{
                    messageId:id
                },
                type: "post",
                async: true,
                success:function(data){
                    table.reloadData('unfinishedprocessauditing');
                    table.reloadData('copyprocess');
                },
                error:function(data) {
                }

            })
        };
            window.addEventListener('message', function(event) {
            if (event.data === 'iframeClosed') {
            // 在这里处理 iframe 关闭事件
            console.log('IFrame 已关闭');
        }
        });
        //实现输入框一键清除
        function clearInput(c){
            if (c == 0){
                $('#applyRealName').val('');
                $('#name').val('');
                $('#telephone').val('');
                $('#paymentMethod').val('');
                $('#transferDateStart').val('');
                $('#transferDateEnd').val('');
                $('#applyTimeStart').val('');
                $('#applyTimeEnd').val('');
                $("#processType").val('');
            }else if (c == 1){
                $('#applyRealName1').val('');
                $('#name1').val('');
                $('#telephone1').val('');
                $('#paymentMethod1').val('');
                $('#transferDateStart1').val('');
                $('#transferDateEnd1').val('');
                $('#applyTimeStart1').val('');
                $('#applyTimeEnd1').val('');
                $("#processType1").val('');
            }else if (c == 2){
                $('#applyRealName2').val('');
                $('#name2').val('');
                $('#telephone2').val('');
                $('#paymentMethod2').val('');
                $('#transferDateStart2').val('');
                $('#transferDateEnd2').val('');
                $('#applyTimeStart2').val('');
                $('#applyTimeEnd2').val('');
                $("#processType2").val('');
            }
            let form = layui.form;
            //需要重新加载一下，这个很重要
            form.render();
        };
        //实现日期输入框全框触发
        layui.use(function() {
            var laydate = layui.laydate;
            // 自定义格式
            laydate.render({
                elem: '.layui-input-date',
                trigger:'click'
            });
        });
        //定时查询未读消息数量，当数量发生变化的时候触发查询按钮
        setInterval(Interval(),5000);//设置轮询时间为5s
        function Interval(){
            $.ajax({
                url:"/HasBeenRead/selectHasBeenRead",
                data:{},
                type: "post",
                async: true,
                success:function(data){
                    if (data.length != 0){//如果不判空那么data[0]报错
                        if (unfinishedprocessauditingNum !== -1){//判断不为-1是为了避免第一次页面刷新两次
                            if (unfinishedprocessauditingNum !== data[0].unfinishedNum){//当两个值不相等的时候触发查找
                                table.reloadData('unfinishedprocessauditing');
                            };
                        };
                        if (finishedprocessauditingNum !== -1){
                            if (finishedprocessauditingNum !== data[1].finishedNum){
                                table.reloadData('finishedprocessauditing');
                            };
                        };
                        if(copyprocessNum !== -1){
                            if (copyprocessNum !== data[2].copyNum){
                                table.reloadData('copyprocess');
                            };
                        };
                        if (data[0].unfinishedNum === 0){
                            unfinishedprocessauditingNum = 0;
                        }else {
                            unfinishedprocessauditingNum = data[0].unfinishedNum;
                        };
                        if (data[1].finishedNum === 0){
                            finishedprocessauditingNum = 0;
                        }else {
                            finishedprocessauditingNum = data[1].finishedNum;
                        };
                        if (data[2].copyNum === 0){
                            copyprocessNum = 0;
                        }else {
                            copyprocessNum = data[2].copyNum;
                        };
                    }else {//如果data为空，给三个数量赋值为0
                        unfinishedprocessauditingNum = 0;
                        finishedprocessauditingNum = 0;
                        copyprocessNum = 0;
                    };

                    //控制三张表的未读消息的数量为0时的隐藏，和从0到有时候的显示
                    if (unfinishedprocessauditingNum <= 0){
                        let t = document.getElementById('unFinished'); //选取id为test的元素
                        t.style.display = 'none';// 隐藏选择的元素
                    }else {
                        document.getElementById("unfinishedprocessauditingNum").innerHTML = unfinishedprocessauditingNum;
                        let t = document.getElementById('unFinished'); //选取id为test的元素
                        t.style.display = '';// （从0到有）取消隐藏选择的元素
                    };
                    if (finishedprocessauditingNum <= 0){
                        let t = document.getElementById('finished'); //选取id为test的元素
                        t.style.display = 'none';// 隐藏选择的元素
                    }else {
                        document.getElementById("finishedprocessauditingNum").innerHTML = finishedprocessauditingNum;
                        let t = document.getElementById('finished'); //选取id为test的元素
                        t.style.display = '';// （从0到有）取消隐藏选择的元素
                    };
                    if (copyprocessNum <= 0){
                        let t = document.getElementById('copy'); //选取id为test的元素
                        t.style.display = 'none';// 隐藏选择的元素
                    }else {
                        document.getElementById("copyprocessNum").innerHTML = copyprocessNum;
                        let t = document.getElementById('copy'); //选取id为test的元素
                        t.style.display = '';// （从0到有）取消隐藏选择的元素
                    };

                },
                error:function(data) {
                }
            })
            return Interval;
        };//轮询方法
        //实现开始的时候三个表的未读消息的红点不显示 隐藏
        function hideTheRedDotsForFirst(){
            let t = document.getElementById('unFinished'); //选取id为test的元素
            t.style.display = 'none';// 隐藏选择的元素
            let t1 = document.getElementById('finished'); //选取id为test的元素
            t1.style.display = 'none';// 隐藏选择的元素
            let t2 = document.getElementById('copy'); //选取id为test的元素
            t2.style.display = 'none';// 隐藏选择的元素
        };

        // function getPositionId() {
        //     $.ajax({
        //         url: '/getPositionId',
        //         type: 'GET',
        //         success: function(response) {
        //             var positionId = response ;
        //             console.log('Process Auditing API Response:', response);
        //             // 在这里处理接口返回的数据
        //         },
        //         error: function(xhr, status, error) {
        //             console.error('Error occurred while calling Process Auditing API:', error);
        //         }
        //     });
        // }

    });
</script>

</body>
</html>